﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace muyu_monitor_plugin
{
    public class MessageConfigItem
    {
        public string ReceiveMessage { get; set; }
        public string SendMessage { get; set; }
        public string PublishTopic { get; set; }
    }
    public class MainWindowViewModel : INotifyPropertyChanged
    {
        private string productKey;
        private string deviceName;
        private string secret;
        private ObservableCollection<MessageConfigItem> messageConfigItems;

        public event PropertyChangedEventHandler PropertyChanged;

        public string ProductKey
        {
            get { return productKey; }
            set
            {
                if (productKey != value)
                {
                    productKey = value;
                    OnPropertyChanged(nameof(ProductKey));
                }
            }
        }

        public string DeviceName
        {
            get { return deviceName; }
            set
            {
                if (deviceName != value)
                {
                    deviceName = value;
                    OnPropertyChanged(nameof(DeviceName));
                }
            }
        }

        public string Secret
        {
            get { return secret; }
            set
            {
                if (secret != value)
                {
                    secret = value;
                    OnPropertyChanged(nameof(Secret));
                }
            }
        }

        public ObservableCollection<MessageConfigItem> MessageConfigItems
        {
            get { return messageConfigItems; }
            set
            {
                if (messageConfigItems != value)
                {
                    messageConfigItems = value;
                    OnPropertyChanged(nameof(MessageConfigItems));
                }
            }
        }

        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
